﻿using System.Windows;
using System.Windows.Controls;

namespace RoleEditer
{
    public partial class Rename_ChildWindow : ChildWindow
    {        
        public Rename_ChildWindow()
        {
            InitializeComponent();
               
        }
        

        public string OldName
        {
            get { return textOldName.Text; }
            set { textOldName.Text = value; }
        }
        public string NewName
        {
            get { return textNewName.Text; }
            set { textNewName.Text = value; }
        }
        public void Show(TreeViewItem_Animat animat)
        {
            OldName = animat.AnimatName;
            Animat = animat;
            Show();
        }
        private TreeViewItem_Animat Animat;
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (NewName.Length <= 0)
            {
                MessageBox.Show("输入新名字");
                return;
            }
            if (NewName == OldName)
            {
                MessageBox.Show("新名字和以前的名字一样");
                return;
            }
            SpiritManager.Instance.Rename(Animat, NewName);
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}

